home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: gets() question
- Date: 08 Jan 1996 15:41:26 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Jan8084126@qcd.lanl.gov>
- References: <4cosgf$rir@newsbf02.news.aol.com> <4cqkt8$1quo@news.gate.net>
- <821109116snz@genesis.demon.co.uk>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: Lawrence Kirby's message of Mon, 08 Jan 96 13:51:56 GMT
-
- --text follows this line--
- In article <821109116snz@genesis.demon.co.uk> Lawrence Kirby
- <fred@genesis.demon.co.uk> writes:
- <snip>
- It is certainly better to use fgets rather than gets but you could have
- written:
-
- fgets(s[0],sizeof s[0],stdin);
-
- s[0] is equivalent to &s[0][0] in this context and is arguably more
- readable. The length argument of fgets specifies the size of the array
-
- Just to point out the obvious, the first s[0] is equivalent to
- &s[0][0]. The s[0] in sizeof s[0] is not!
-
- (argument of sizeof and argument of & are two conditions unders which
- s[0] will not `decay' into &s[0][0].)
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-